//
//  PaypwdMController.m
//  WaywardPoint_Code
//
//  Created by 韩盼盼 on 15/9/28.
//  Copyright (c) 2015年 易网新科技. All rights reserved.
//

#import "PaypwdMController.h"
#import "ModifyPaypwdController.h"
#import "ForgetPaypwdController.h"
#import "MailboxBindingVC.h"//邮箱找回
@interface PaypwdMController ()
{
    UIButton *gobackBtn;
    UIView *view_cover;//这盖面
    UIView *view_popBG;//弹出视图
}
@property(nonatomic,strong)ModifyPaypwdController *modifypaywpdVc;
@property(nonatomic,strong)ForgetPaypwdController *forgetVc;
@end

@implementation PaypwdMController
-(ForgetPaypwdController *)forgetVc
{
    if (!_forgetVc) {
        _forgetVc=[[ForgetPaypwdController alloc]init];
    }
    return _forgetVc;
}

-(ModifyPaypwdController *)modifypaywpdVc
{
    if (!_modifypaywpdVc) {
        _modifypaywpdVc=[[ModifyPaypwdController alloc]init];
    }
    return _modifypaywpdVc;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController addChildViewController:self];
    
    self.title = @"交易密码管理" ;


    [self showUI];
}

- (void)showUI
{
    UIView *contentView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, ScreenW, ScreenH-64)];
    contentView.backgroundColor = COLOR_EVERYVIEWBG;
    [self.view addSubview:contentView];
    
    UIView *content_1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    content_1.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:content_1];
    UIImageView *content_1Img=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    content_1Img.image=[UIImage imageNamed:@"payment_7"];
    [content_1 addSubview:content_1Img];
    
    UILabel *content_1lab=[[UILabel alloc]initWithFrame:CGRectMake(content_1Img.width+content_1Img.x+5, 8, 130, 25)];
    content_1lab.text=@"修改交易密码";
    content_1lab.font=[UIFont boldSystemFontOfSize:Font_SIZE_14];
    [content_1 addSubview:content_1lab];
    UIImageView *cimg1=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenW-28, 10, 22, 22)];
    cimg1.image=[UIImage imageNamed:@"return_1"];
    [content_1 addSubview:cimg1];
    content_1lab.textColor = [UIColor grayColor];
    //balancedetail
    UIButton *modifyBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    [modifyBtn addTarget:self action:@selector(modifyBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    [content_1 addSubview:modifyBtn];

    UIView *content_2=[[UIView alloc]initWithFrame:CGRectMake(0, content_1.y+content_1.height+2, ScreenW, 45)];
    content_2.backgroundColor = [UIColor whiteColor];
    [contentView addSubview:content_2];
    
    UIImageView *content_2Img=[[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    content_2Img.image=[UIImage imageNamed:@"payment_6"];
    [content_2 addSubview:content_2Img];
    
    UILabel *content_2lab=[[UILabel alloc]initWithFrame:CGRectMake(content_2Img.width+content_2Img.x+5, 8, 130, 25)];
    content_2lab.text=@"找回交易密码";
    content_2lab.font=[UIFont boldSystemFontOfSize:Font_SIZE_14];
    [content_2 addSubview:content_2lab];
    UIImageView *cimg2=[[UIImageView alloc]initWithFrame:CGRectMake(ScreenW-28, 10, 22, 22)];
    cimg2.image=[UIImage imageNamed:@"return_1"];
    [content_2 addSubview:cimg2];
    content_2lab.textColor = [UIColor grayColor];
    
    //balancedetail
    UIButton *forgetBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, ScreenW, 45)];
    [forgetBtn addTarget:self action:@selector(forgetBtnEvent) forControlEvents:UIControlEventTouchUpInside];
    [content_2 addSubview:forgetBtn];
    

}
- (void)modifyBtnEvent
{
    self.modifypaywpdVc.memberid=_memberid;

    [self.navigationController pushViewController:self.modifypaywpdVc animated:YES];
}

//忘记交易密码
- (void)forgetBtnEvent
{
    [self choseAvatarFromLibraryAction];
    
}

#pragma mark --- 忘记密码？
- (void) choseAvatarFromLibraryAction
{
    view_cover = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    [self.view addSubview:view_cover];
    view_cover.backgroundColor = [UIColor blackColor];
    view_cover.alpha = 0.5;
    
    //添加手势
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapHandle)];
    [view_cover addGestureRecognizer:gesture];
    
    view_popBG = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight-220, kScreenWidth, 220)];
    [self.view addSubview:view_popBG];
    view_popBG.backgroundColor = [UIColor whiteColor];
    
    [self forgetPasswordFindPopView];
}

#pragma mark - popView 弹出的视图
- (void) forgetPasswordFindPopView
{
    NSArray *array_title = @[@"通过手机号码找回",@"通过绑定邮箱找回"];
    for (int i=0; i<3; i++) {
        CGFloat buttonY = (40+20)*i;
        UIButton *button_action = [[UIButton alloc] initWithFrame:CGRectMake(20, 20 + buttonY, kScreenWidth-40, 50)];
        [view_popBG addSubview:button_action];
        
        button_action.tag = 20+i;
        
        button_action.layer.cornerRadius = 3.0;
        button_action.clipsToBounds = YES;
        
        if (i==2) {
            button_action.backgroundColor = RXDColor(179, 179, 179);
            
            [button_action setTitle:@"取消" forState:UIControlStateNormal];
        }
        else
        {
            button_action.layer.borderColor = RXDColor(233, 233, 233).CGColor;
            button_action.layer.borderWidth = 1.0;
            [button_action setTitle:array_title[i] forState:UIControlStateNormal];
            [button_action setTitleColor:RXDColor(110, 110, 110) forState:UIControlStateNormal];
            
        }
        [button_action addTarget:self action:@selector(findPasswordStyle:) forControlEvents:UIControlEventTouchUpInside];
    }
}

//找回密码
- (void) findPasswordStyle:(UIButton *)sender
{
    if (sender.tag==20) {
        
        self.forgetVc.userIphone=_userIphone;
        self.forgetVc.memberid=_memberid;
        self.forgetVc.payjumpStr=@"PasswordSetVC";
        [self.navigationController pushViewController:self.forgetVc animated:YES];

    }
    if (sender.tag==21) {
#warning 邮箱找回 验证码
        MailboxBindingVC *mailboxView = [[MailboxBindingVC alloc] init];
        mailboxView.str_title = @"找回交易密码";
        mailboxView.str_fromeWhere = @"tradePwd";
        [self.navigationController pushViewController:mailboxView animated:YES];
    }
    if (sender.tag==22) {
        
    }
    if (sender.tag==23) {
        
    }
    
    [view_popBG removeFromSuperview];
    [view_cover removeFromSuperview];
}

//手势移除
- (void) tapHandle
{
    
    [view_popBG removeFromSuperview];
    [view_cover removeFromSuperview];
}

- (void)btnback
{

    [self.navigationController popViewControllerAnimated:YES];
}
@end
